package com.situ.mall.service.impl;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.situ.mall.common.ServerResponse;
import com.situ.mall.dao.UserMapper;
import com.situ.mall.entity.User;
import com.situ.mall.service.IUserService;

@Service
public class UserServiceImpl implements IUserService{
	@Autowired
	private UserMapper userMapper;

	@Override
	public ServerResponse login(String username, String password, HttpSession session) {
		User user = userMapper.login(username, password);
		if (user != null) {
			session.setAttribute("user", user);
			return ServerResponse.createSuccess("登录成功");
		}
		return ServerResponse.createError("登录失败");
	}


}
